package com.sghd.candy.module.shop.facade;

import com.sghd.candy.module.bag.service.PlayerBagService;
import com.sghd.candy.module.player.manager.Player;
import com.sghd.candy.module.player.service.PlayerService;
import com.sghd.candy.module.shop.service.ShopService;
import com.sghd.common.event.EventBus;
import com.sghd.pojo.candy.shop.vo.ShopVo;
import com.sghd.pojo.fight.game.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Allen
 * @date 2019/01/09
 */
@Component
public class ShopFacadeImpl implements ShopFacade {
    @Autowired
    private PlayerService playerService;
    @Autowired
    private PlayerBagService playerBagService;
    @Autowired
    private ShopService shopService;
    @Autowired
    private EventBus eventBus;
    @Override
    public List<ShopVo> shopList(long playerId) {
        return shopService.list(playerService.load(playerId));
    }

    @Override
    public Result<String> shopBuy(long playerId, String shopId) {
        Player player = playerService.load(playerId);
        return shopService.buy(player, shopId);
    }
}
